#!/bin/bash
#Filename:Redhat-6.4_x86-64-update-yum.repos.sh
#Author:SuJunQuan
#Email:junquan.su@jwis.cn
#Date:2017-03-02
#Desc:redhat6.4, 6.6测试通过

#备份系统源有的yum源文件
mv /etc/yum.repos.d/rhel-source.repo /etc/yum.repos.d/rhel-source.repo.bak

#卸载系统yum
rpm -qa |grep yum|xargs rpm -e --nodeps

#卸载python-urlgrabber-3.9.1-9.el6.noarch
rpm -e python-urlgrabber-3.9.1-9.el6.noarch --nodeps

#下载相关rpm包
wget http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-filter-data-1.1.30-37.el6.noarch.rpm
#下载163yum源仓库文件
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

#导入RPM-GPG-KEY-CentOS
rpm --import RPM-GPG-KEY-CentOS-6
#安装相关rpm包
rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm --nodeps
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm yum-plugin-filter-data-1.1.30-37.el6.noarch.rpm --nodeps
#将CentOS6-Base-163.repo拷贝到/etc/yum.repos.d
cp CentOS6-Base-163.repo /etc/yum.repos.d
#将/etc/yum.repos.d/CentOS6-Base-163.repo文件里的$releasever关键字改为6
sed -i 's/$releasever/6/g' /etc/yum.repos.d/CentOS6-Base-163.repo
#清除缓存
yum clean all
#配置获取yum列表
